home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
VISUALBA
/
BOZOL2.ZIP
/
CUSTOM.BAS
< prev
next >
Wrap
BASIC Source File
|
1994-02-08
|
2KB
|
79 lines
SUB BROWSE(A$, TopView%, LeftView%,BottomView%, RightView%)
WideNess%=RightView%-LeftView%
Ptr%=1 ' starting byte for view (1 is top of file)
Offset%=0 ' horizontal movement
DO
TempPtr% = Ptr% : Temp% = TopView%
DO
' TempPtr% is byte position of current line, calculate offset of end of line
eol% = Instr(Mid$(A$,TempPtr%),Chr$(13))
' if there are no more carriage returns, then eol% is the end of A$
if eol%=0 then eol%=LEN(A$) ELSE DECR eol% ' DECR: do not show the CR
' get the current line as Curr$
Curr$ = Mid$(A$, TempPtr%,eol%)
' display the current line
Locate Temp%, LeftView%
PRINT Mid$(Curr$+Space$(WideNess%+Offset%), 1+Offset%,WideNess%)
' increment the pointer to the next line to display in the window
TempPtr% = Instr(TempPtr%, A$, Chr$(13)) + 2 ' +2 for CRLF pair
' if we have reached the end then we don't show any more
If TempPtr%=2 Then TempPtr%=LEN(A$)
' get ready to display the next line...
INCR Temp%
' inless we are done, in which case, we have finished with the screen
if Temp% > BottomView% THEN Exit LOOP
LOOP
' now, we need a keystroke to tell us which way to browse around
DO:LOOP WHILE NOT INSTAT
KB$=INKEY$
SELECT CASE KB$
CASE CHR$(0,&H50) 'dn arrow
IF TempPtr% < LEN(A$) THEN
Ptr%=Instr(Ptr%, A$, Chr$(13) ) + 2
ELSE
Sound 100,.1 ' we are at the end
END IF
CASE CHR$(0,&H48) 'up arrow
IF Ptr% > 1 THEN
' search backwards for a CR or 1
DECR Ptr%:IF Ptr%>1 then DECR Ptr%
DO:DECR Ptr%:LOOP UNTIL Mid$(A$, Ptr%, 1)=CHR$(13) OR Ptr%=1
IF Ptr%>1 THEN INCR Ptr%:INCR Ptr%
ELSE
Sound 100,.1 ' we are at the beginning
END IF
CASE CHR$(0,&H47) 'home
If Offset% THEN Offset% = 0 ELSE Ptr%=1
CASE CHR$(0, &H4D) ' right arrow
INCR Offset%
CASE CHR$(0,&H4B) ' left arrow
If Offset% THEN DECR Offset%
CASE CHR$(0,&H51) ' page down
FOR pd = TopView% to BottomView%-1
OldPtr%=Ptr%
Ptr%=Instr(Ptr%, A$, Chr$(13) ) + 2
if Ptr%=2 then Ptr%=OldPtr%:Exit FOR
Next Pd
CASE CHR$(0, &H49) ' page up
FOR pd = TopView% to BottomView% -1
IF Ptr% > 1 THEN
' search backwards for a CR or 1
DECR Ptr%:IF Ptr%>1 then DECR Ptr%
DO:DECR Ptr%:LOOP UNTIL Mid$(A$, Ptr%, 1)=CHR$(13) OR Ptr%=1
IF Ptr%>1 THEN INCR Ptr%:INCR Ptr%
ELSE
EXIT FOR
END IF
NEXT Pd
CASE ELSE
END SELECT
IF KB$=CHR$(27) THEN EXIT LOOP
LOOP
'''' THAT'S ALL FOLKS! EDITING ROUTINES TO FOLLOW!
END SUB